﻿

using SJM.ResultCore;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace SJM.ResultCore
{
    public record ResultSet<T> : Result<List<T>>
    {
        public int Total { get; set; }

        public ResultSet()
        {
        }

        public ResultSet(List<T> dataSet)
            : base(dataSet)
        {
            Total = dataSet.Count;
        }

        public ResultSet(List<T> dataSet, int total)
            : base(dataSet)
        {
            Total = total;
        }

        public ResultSet(string msg, bool isOK = false)
            : base(msg, isOK)
        {
        }

        [CompilerGenerated]
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("ResultSet");
            stringBuilder.Append(" { ");
            if (PrintMembers(stringBuilder))
            {
                stringBuilder.Append(' ');
            }

            stringBuilder.Append('}');
            return stringBuilder.ToString();
        }

        [CompilerGenerated]
        protected override bool PrintMembers(StringBuilder builder)
        {
            if (base.PrintMembers(builder))
            {
                builder.Append(", ");
            }

            builder.Append("Total = ");
            builder.Append(Total.ToString());
            return true;
        }

        [CompilerGenerated]
        public override int GetHashCode()
        {
            return base.GetHashCode() * -1521134295 + EqualityComparer<int>.Default.GetHashCode(Total);
        }

        [CompilerGenerated]
        public virtual bool Equals(ResultSet<T>? other)
        {
            return (object)this == other || (base.Equals(other) && EqualityComparer<int>.Default.Equals(Total, other!.Total));
        }

        [CompilerGenerated]
        protected ResultSet(ResultSet<T> original)
            : base((Result<List<T>>)original)
        {
            Total = original.Total;
        }
    }
}
